package com.ftg.learn.mapper;

import com.ftg.learn.entity.SysPermission;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 描述
 *
 * @author 布衣
 * @date 2025/8/14
 */
@Mapper
public interface SysPermissionMapper {

    @Select("select id, parent_id parentId, name, url, icon, type, gmt_create, gmt_modified from sys_permission")
    List<SysPermission> list();


    @Select("select distinct p.id, p.parent_id parentId, p.name, p.url, p.icon, p.type, p.gmt_create, p.gmt_modified from sys_permission p " +
            "join sys_role_permission srp on p.id = srp.permission_id " +
            "join sys_user_role sur on srp.role_id = sur.role_id " +
            "where sur.user_id = #{id}")
    List<SysPermission> listById(@Param("id") Long id);
}
